package com.sl.biz.modular.product.dao.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.product.dao.entity.ProductDO;
import com.sl.biz.modular.product.dao.mapper.ProductMapper;
import com.sl.biz.modular.product.dao.service.ProductDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ProductDaoServiceImpl extends ServiceImpl<ProductMapper, ProductDO> implements ProductDaoService {

    @Override
    public List<ProductDO> queryByList() {
        LambdaQueryWrapper<ProductDO> wrapper = Wrappers.lambdaQuery();
//        wrapper.eq(ProcessDataSourceDO::getGroupId, groupId);
        List<ProductDO> list = baseMapper.selectList(wrapper);
        return list;
    }

    @Override
    public ProductDO queryByCode(String productCode) {
        LambdaQueryWrapper<ProductDO> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ProductDO::getProductCode, productCode);
        List<ProductDO> list = baseMapper.selectList(wrapper);
        return CollUtil.get(list,0);
    }
}
